package com.zhuzg.controller;



import com.zhuzg.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

@RestController
@RequestMapping("store")
@Primary
public class StoreController {

    @Resource  // jdk  注解  根据名字从容器查找


    // spring 注解 根据类型从容器当中查找
    // 如果容器当中有重名的对象，则可能报错，解决办法 1）@Qualifier("")
    //  办法2）： 在实例化的时候加上 @Primary  ，这样重名的时候优先加载这个
    @Autowired
    StoreService storeService;


    /**
     *
     * @param goodsId
     * @param num
     * @return
     */
    @RequestMapping("deduce")
    public String deduce(@RequestParam("gid") Integer goodsId,
                         @RequestParam("num")Integer  num){

        storeService.deduceStore(goodsId,num);
        return "ok";


    }

}
